
{include file="public/header" /}
</head>
<body>
<div class="panel admin-panel margin-top">
  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>添加菜单</strong></div>
  <div class="body-content">
    <form id="form" method="post" class="form-x" action="">
        <div class="form-group">
	 <div class="label">
          <label>上级：</label>
        </div>
        <div class="field">
          <select name="pid" class="input w50">
		  <option value="0">顶级分类</option>
		  {foreach name='list' item='val'}
             <option value="{$val.id}" {if $val.id eq $id}selected="selected"{/if}> {$val.name}</option>
           {/foreach}
          </select>
        </div>
	</div>      
      <div class="form-group">
        <div class="label">
          <label> 菜单名称：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" name="name" value=""   data-validate="required:菜单名称不能为空"/>
          <div class="tips"></div>
        </div>
      </div>        
      <div class="form-group">
        <div class="label">
          <label> 类名：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" name="module_name" value=""/>         
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label> 方法名：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" name="action_name" value=""/>         
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label> 参数：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" name="other_para" value=""/>        
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>排序：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" name="ordid" value="255"  data-validate="number:必须是数字，且不超过255;?>" />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <a class="button bg-main icon-check-square-o"  onclick="submit()"> 提交</a>
        </div>
      </div>
    </form>
  </div>
</div>
<script>
  function submit(){
    var data=new FormData($("#form")[0]);
    $.ajax({
      type:"post",
      url:"{:U('menu/add')}",
      data:data,
      dataType:"json",
      processData:false,
      contentType:false,
      success:function(rs){
        layer.msg(rs.msg);
        if(rs.res==1 && rs.data.url !=undefined){
          window.location=rs.data.url;
        }
      }
    });
  }

</script>
{include file="public/footer" /}